package com.ljs.staticPool
{
	import com.ljs.vo.WorldVo;

	public class StaticWorldPool
	{
		private static var _instance:StaticWorldPool;
		private var _datapool:Array=[];
		public function StaticWorldPool()
		{
			if(_instance==null)
			{
				_instance=this;
			}
			init();
		}
		
		public static function getInstance():StaticWorldPool
		{
			if(_instance==null)
			{
				_instance=new StaticWorldPool();
			}
			
			return _instance;
		}
		
		private function init()
		{
			var i:int=0;
			for(i=1;i<2;i++)
			{
				var v:WorldVo=new WorldVo;
				v.startX=30;
				v.startY=100;
				v.worldId=i;
				v.endX=750;
				v.endY=100;
				v.mapData=[];
				v.roleArray=[];
				_datapool.push(v);
			}
		}
		
		public function getWorldDataById(id:int):WorldVo
		{
			var i:int=0;
			for(i=0;i<_datapool.length;i++)
			{
				var v:WorldVo=_datapool[i] as WorldVo;
				if(v&&v.worldId==id)
				{
					var vo:WorldVo=new WorldVo;
					vo.startX=v.startX;
					vo.startY=v.startY;
					vo.worldId=v.worldId;
					vo.endX=v.endX;
					vo.endY=v.endY;
					vo.mapData=v.mapData;
					vo.roleArray=v.roleArray;
					return vo;
					break;
				}
			}
			return null;
		}
	}
}